package com.dxy.df.modules.controller;

import com.dxy.df.constants.ConstStrings;
import com.dxy.df.core.model.Rs;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author admin
 * @Description:
 * @date 2018/5/15 下午5:11
 */
@Controller
@RequestMapping("/api/tokencreate")
public class DebugLoginController {
    @GetMapping
    @ResponseBody
    public Rs createToken(HttpServletRequest request, HttpServletResponse response) {
        String projectType = System.getProperty(ConstStrings.SPRING_PROFILES_ACTIVE);
        if (projectType.equals("local")) {
            String dxyUserName = request.getParameter("dxyUserName");
            Cookie cookie = new Cookie("testDebugDxyUserName", dxyUserName);
            response.addCookie(cookie);
        }
        return new Rs();
    }
}
